import DB from "./DB.js";
import objectStoreList from "./modules/index.js";
import actions from "./actions/index.js";

(async () => {
  try {
    // 获取自己封装的操作数据库实例
    let dbInstance = new DB({ dbName: "dbText", dbVersion: 1 });

    // 打开数据库、初始化表
    await dbInstance.initDb(objectStoreList);

    console.log("数据库及表初始化成功");

    window.$dbInstance = dbInstance;
    // 初始化接口
    window.$dbActions = actions.init(dbInstance);
  } catch (err) {
    console.log("操作数据库异常", err);
  }
})();
